import datetime

from .util import get_current_url_root


class SignRequest(object):
    def __init__(self, amount, currency, trade_code, description, gateway_ext={}, **kwargs):
        self.amount = amount
        self.trade_code = trade_code
        self.description = description
        self.currency = currency
        self.gateway_ext = gateway_ext
        self.kwargs = kwargs
        self.payment_time = datetime.datetime.now()
        self.links = kwargs.pop('links')


class VerifyRequest(object):
    def __init__(self, options={}, **kwargs):
        self.fund_channel = kwargs.pop('fund_channel')
        self.gateway_ext = kwargs.pop('gateway_ext')
        self.payment_journal = kwargs.pop('payment_journal')
        self.gateway_journal = kwargs.pop('gateway_journal')
        self.options = options

class Response(object):
    def __init__(self, success, **kwargs):
        self.success = success
        self.message = kwargs.pop('message', None)
        self.extension = {}


class VerifyResponse(Response):
    def __init__(self, success, **kwargs):
        Response.__init__(self, success, **kwargs)
        self.return_info = kwargs.pop('return_info', None)
        self.trade_code = kwargs.pop('trade_code', None)
        self.return_code = kwargs.pop('return_code', None)
        self.return_message = kwargs.pop('return_message', None)
        self.amount = kwargs.pop('amount', None)
        self.fee = kwargs.pop('fee', None)


class ApprovalLink(object):
    def __init__(self):
        self.href = None
        self.method = None
        self.extra_fields = {}


class SignResponse(Response):
    def __init__(self, success, **kwargs):
        Response.__init__(self, success)
        self.trade_code = None
        self.approval = ApprovalLink()
